from drf_spectacular.plumbing import build_object_type


def get_error_schema(errors=None):
    return build_object_type({
        'error': {
            'type': 'string',
            'description': 'Machine readable error indicating what went wrong.',
            'enum': errors
        },
        'detail': {
            'oneOf': [
                {
                    'type': 'string',
                    'format': 'string',
                    'description': 'Human readable details about what went wrong.'
                },
                {
                    'type': 'object',
                    'format': 'object',
                    'description': 'Machine readable object about what went wrong.'
                }
            ]
        }
    })
